﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/App.Master" Inherits="System.Web.Mvc.ViewPage<Ornament.Messages.Info>" %>

<%@ Import Namespace="Ornament.Messages" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset class="cssform">
        <p>
            <label>
                Message type</label>
            <label class="Data">
            
            <%=Model.Type.Name %></label>
        </p>
        <p>
            <textarea id="content"><%=Model.Message.Value%></textarea>
        </p>
    </fieldset>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="<%=Url.Content("~/Scripts/Lib/fg-menu/fg.menu.css") %>" rel="stylesheet"
        type="text/css" />
    <script src="<%=Url.Content("~/Scripts/Lib/fg-menu/fg.menu.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/ckeditor/ckeditor.js") %>" type="text/javascript"></script>
    <style type="text/css">
        .ui-icon
        {
            display: inline-block;
        }
        #ParentName
        {
            width: 150px;
        }
        .fg-button
        {
            clear: left;
            margin: 0 4px 40px 0px;
            padding: .2em 1em;
            text-decoration: none !important;
            cursor: pointer;
            position: relative;
            text-align: center;
            zoom: 1;
        }
        .fg-button .ui-icon
        {
            position: absolute;
            top: 50%;
            margin-top: -8px;
            left: 50%;
            margin-left: -8px;
        }
        button.fg-button
        {
            width: auto;
            overflow: visible;
        }
        /* removes extra button width in IE */
        
        .fg-button-icon-left
        {
            padding-left: 2.1em;
        }
        .fg-button-icon-right
        {
            padding-right: 2.1em;
        }
        .fg-button-icon-left .ui-icon
        {
            right: auto;
            left: .2em;
            margin-left: 0;
        }
        .fg-button-icon-right .ui-icon
        {
            left: auto;
            right: .2em;
            margin-left: 0;
        }
        .fg-button-icon-solo
        {
            display: block;
            width: 8px;
            text-indent: -9999px;
        }
        /* solo icon buttons must have block properties for the text-indent to work */
        
        .fg-button.ui-state-loading .ui-icon
        {
            background: url(spinner_bar.gif) no-repeat 0 0;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            CKEDITOR.replace('content');

            $('#ParentName').menu({
                content: $('#infoTypeSelectorPanel').html(),
                //backLink: false,
                crumbDefaultText: "选择所属消息类型",
                //flyOut: true,
                chooseItem: function (item) {
                    this.kill();
                    $("#ParentId").val(GetId(item));
                    $("#ParentName").children("span:eq(1)").text($(item).text());
                }
            });
        });
        function GetId(target) {
            var id = $(target).attr("href");
            var position = id.indexOf("#") + 1;
            return id.substr(position);
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageTitle" runat="server">
</asp:Content>
<script type="text/C#" runat="server">
    private void Build(IEnumerable<InfoType> childNodes)
    {

        foreach (var node in childNodes)
        {
            if (node.Count == 0)
            {
                Response.Write(String.Format(("<li><a href='#{0}'>{1}</a></li>\r\n"), node.Id.ToString(), node.Name));
            }
            else
            {
                Response.Write(String.Format(("<li><a href='#{0}'>{1}</a>\r\n"), node.Id.ToString(), node.Name));
                Response.Write("<ul>\r\n");
                this.Build(node.GetChilds());
                Response.Write("</ul>\r\n");
                Response.Write("</li>\r\n");
            }


        }
    }
</script>
